/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package wli.web.java.db;

import java.util.Date;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;

/**
 *
 * @author wli
 */
@ManagedBean
@SessionScoped
public class SpellingStudyController {

    private DataModel spellingStudyList;
    private DataModel spellingStudyListCurrent;
    private SpellingStudyHelper sshelper;
    private SpellingStudy current;
    //private String selected_date;
    private Date selected_date;

    /** Creates a new instance of SpellingStudyController */
    public SpellingStudyController() {
        this.sshelper = new SpellingStudyHelper();
    }

    public DataModel getSpellingStudyList() {
        if (spellingStudyList == null) {
            System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>SpellingStudyController:getVocabularyList>>>>>>>>>>>>>>>>>>>>>>>>");
            spellingStudyList = new ListDataModel(sshelper.getSpellingStudyList());
        }
        return spellingStudyList;
    }

    public String prepareView() {
        //System.out.println("====================SpellingStudyontroller:prepareView================" + current.getDate());
        current = (SpellingStudy) getSpellingStudyList().getRowData();
        //System.out.println("====================SpellingStudyontroller:prepareView=========....=======" + current.getWord());
        System.out.println("==================SpellingStudyontroller:prepareView================" + current.getDate());
        selected_date = current.getDate();
        return "index3";
    }

    public DataModel getSelectedList() {
        //System.out.println("====================SpellingStudyontroller:prepareView========++++++++++++++++++++aaaaaaaaaaaa+++++++++++++++++========"+selected_date);
        spellingStudyListCurrent = new ListDataModel(sshelper.getSpellingStudyList(selected_date));
        //System.out.println("====================SpellingStudyontroller:prepareView========+++++++++++++++++++++++++++bbbbbbbbbbbbbbb++++++++++========"+selected_date);
        return spellingStudyListCurrent;
    }
    
}
